package priorityqueue;

import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;

public class PQueue {
    public static void main1(String[] args) {
        PriorityQueue<Integer> pq = new PriorityQueue<>();
        pq.offer(1);
        pq.offer(44);
        pq.offer(55);
        pq.offer(22);
        pq.offer(33);
        pq.offer(11);

        System.out.println(pq.poll());


        System.out.println(pq.peek());
        System.out.println(pq.peek());

    }
}
class Student implements Comparable<Student>{
    String name;
    int age;

    public Student() {

    }

    public Student(String name,int age) {
        this.name = name;
        this.age = age;

    }

    public int compareTo(Student s){
        return this.age-s.age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public static void main2(String[] args) {
        Student[] students = new Student[4];
        Student s1 = new Student("xishi",23);
        Student s2 = new Student("diaochan",28);
        Student s3 = new Student("wangzhaojun",28);
        Student s4 = new Student("yangyuhuan",25);
        students[0] = s1;
        students[1] = s2;
        students[2] = s3;
        students[3] = s4;

        Arrays.sort(students);
        System.out.println(Arrays.toString(students));
    }

}



//爷爷类
class Ye {
    public String show(Sun obj) {
        return ("Ye and Sun");
    }

    public String show(Ye obj) {
        return ("Ye and Ye");
    }

}
//爸爸类
class Fu extends Ye {
    public String show(Fu obj) {
        return ("Fu and Fu");
    }

    public String show(Ye obj) {
        return ("Fu and Ye");
    }
}
//儿子类
class Zi extends Fu {

}
//孙子类
class Sun extends Fu {

}

class PolymorphicTest {
    public static void main(String[] args) {

        String s = "zghsa";
        int a = 0;
//        Ye y = new Ye();
//        Ye y2 = new Fu(); //向上
//        Fu f = new Fu();
//        Zi z = new Zi();
//        Sun s = new Sun();
//
//
//        System.out.println("第一题 " + y.show(f));
//        System.out.println("第二题 " + y.show(z));
//        System.out.println("第三题 " + y.show(s));
//        System.out.println("第四题 " + y2.show(f));
//        System.out.println("第五题 " + y2.show(z));
//        System.out.println("第六题 " + y2.show(s));
//        System.out.println("第七题 " + f.show(f));
//        System.out.println("第八题 " + f.show(z));
//        System.out.println("第九题 " + f.show(s));

    }
}